﻿@model IEnumerable<eBusiness.Models.Category>
<table class="dashboardTable">
    <tr>
        <th>
            Name
        </th>
        <th>
            CreatedBy
        </th>
        <th>
            CreatedDate
        </th>
        <th>
            IsMenu
        </th>
        <th>
            Parent Category
        </th>
        <th>
            Childs Category
        </th>
    </tr>
    @foreach (var item in Model)
    {
        @Html.HiddenFor(modelItem => item.ID)
        <tr>
            <td>
                <a href="@Url.Action("Details", "Categories", new { id = @item.ID })">@Html.DisplayFor(modelItem => item.Name)</a>
            </td>
            <td>
                @{
                        if (!string.IsNullOrEmpty(item.CreatedBy.ToString()))
                    {
                        var membershipUser = Membership.GetUser(item.CreatedBy);
                        if (membershipUser != null)
                        {
                            var usr = membershipUser.UserName;
                            @usr
                        }
                    }
                }
            </td>
            <td>
                @if (!string.IsNullOrEmpty(@item.CreatedDate.ToString()))
                            {
                                @item.CreatedDate.ToString("dd/MM/yyyy")
                            }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.IsMenu)
            </td>
            <td>
                <a href="@Url.Action("Details", "Categories", new { id = @item.ParentID })">@Html.DisplayFor(modelItem => item.Parent.Name)</a>
            </td>
            <td>
                @foreach (var child in item.Childs)
                {
                    <a href="@Url.Action("Details", "Categories", new { id = @child.ID })">@Html.DisplayFor(modelItem => child.Name)</a>
                    @:,
                                                                            }
            </td>
        </tr>
    }
</table>
